package com.qs.education.bean.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Getter;
import lombok.Setter;

/**
 * 
 * @class EducationRole.java 后台角色实体类
 * @author Arwen Liu
 * @description	
 * @date 2018-10-24
 */

@Entity
@Getter
@Setter
@Table(name="education_role",uniqueConstraints={@UniqueConstraint(columnNames={"name"})})
public class EducationRole {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	
	private String name;
	
	private String description;
	
	@ManyToMany(mappedBy="roles")
	private Set<EducationAdmin> admins = new HashSet<>();
	
	@ManyToMany
	@JoinTable(
		name="education_role_permission",
		joinColumns={@JoinColumn(name="role_id",referencedColumnName="id")},
		inverseJoinColumns={@JoinColumn(name="permission_id",referencedColumnName="id")}
	)
	@JsonIgnoreProperties(value = { "roles" })
	private Set<EducationPermission> permissions = new HashSet<>();
	

}
